$(function(){
    $("#register_button").on('click',function(){
        var username = $("#username").val();
        var mobile = $("#mobile").val();
        var password = $("#password").val();

        if(username=="" || username==null || mobile=="" || mobile==null ||password=="" || password==null){
            layer.msg('数据不能为空......',{icon:2,shade:0.6,time: 700});
            return false;
        };

        $.ajax({
            url : "/ajaxRegister",
            type : "POST",
            data : {username:username,mobile:mobile,password:password},
            dataType : "json",
            success : function(data) {
                console.log("stats"+data.stats);
                if(data.stats=="200"){
                    layer.msg(data.messages, {
                        icon: 1,
                        shade:0.6,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        window.location.href = "/login";
                    });
                }else{
                    layer.msg(data.messages, {
                        icon: 2,
                        shade:0.6,
                        time: 1000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){
                    });
                }
            }
        });
    });

});